/**
 * 
 */
package com.james.wee.shuangseqiu.zuma;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

import com.james.wee.shuangseqiu.bo.Cardno;
import com.james.wee.shuangseqiu.bo.IDBBo;
import com.james.wee.shuangseqiu.bo.OpenNumber;
import com.james.wee.shuangseqiu.db.DB;
import com.james.wee.shuangseqiu.tools.ToolsUtil;

/**
 * @author James
 * 
 */
public class ZuMa {

	private static int calc(String str) {
		String[] ses = str.split(",");
		int total = 0;
		for (String s : ses)
			total += Integer.parseInt(s);
		return total;
	}

	public static void cnt() throws Exception {
		List<IDBBo> listcard = DB.getInstance().queryBoList(
				"SELECT * FROM CARDNO order by id asc", Cardno.class);
		List<IDBBo> list = DB.getInstance().queryBoList(
				"SELECT * FROM OpenNumber  order by id desc", OpenNumber.class);
		Cardno cardno = null;
		Class cardcla = Cardno.class;
		Class opencla = OpenNumber.class;
		OpenNumber open = null;
		Method method = null;
		Method openMet = null;
		List<String> cntlist5 =null;// new ArrayList<String>();
		List<String> cntlist6 = null;//new ArrayList<String>();
		for (IDBBo bio : listcard) {
			cardno = (Cardno) bio;

			String value = null;
			String tmp = "";
			cntlist5 = new ArrayList<String>();
			cntlist6 = new ArrayList<String>();
			for (IDBBo bo : list) {
				open = (OpenNumber) bo;
				int res = 0;
				for (int i = 1; i <= 6; i++) {
					openMet = opencla.getDeclaredMethod("getN_" + i);
					tmp = openMet.invoke(open, null).toString();
					method = cardcla.getDeclaredMethod("get"
							+ ToolsUtil.getStr(tmp));
					value = method.invoke(cardno, null).toString();
					if (tmp.equals(value)) {
						res++;
					}
				}
				if(res==5)
					cntlist5.add(open.getOpennum()+"==>"+res);
				else if(res==6)
					cntlist6.add(open.getOpennum()+"==>"+res);
				//System.out.println(open.getOpennum() + "==> " + res);
			}
//			System.out.println("组码："+cardno.getId()+"==>"+cntlist6.size());
			System.out.println("组码："+cardno.getId()+"==>"+cntlist5.size());
		 
		}
		
	}

	public static void main(String[] args) {
		try {
			cnt();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// try {
		// List<IDBBo> list = DB.getInstance().queryBoList(
		// "SELECT * FROM OpenNumber order by id asc",
		// OpenNumber.class);
		// OpenNumber on = null;
		// // int total = 0;
		// for (int i = 0, len = list.size(); i < len; i++) {
		//
		// on = (OpenNumber) list.get(i);
		// // if (i % 29 != 0) {
		// int total = calc(on.getZumamaping());
		// // }else{
		// System.out.println(on.getOpennum() + ":" + total);
		// // total =0;
		// // total += calc(on.getZumamaping());
		// // }
		// }
		// } catch (Exception e) {
		// // TODO Auto-generated catch block
		// e.printStackTrace();
		// }
	}
}
